package com.yanchangapp.widget.calendar;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

import com.haibin.calendarview.CalendarLayout;

/**
 * Created by apple on 2019-11-07.
 * description:
 */
public class MyCalendarLayout extends CalendarLayout {
    private int lastX;
    private int lastY;

    public MyCalendarLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        int x = (int) ev.getX();
        int y = (int) ev.getY();
        switch (ev.getAction()){
            case MotionEvent.ACTION_DOWN:
                lastX = (int) ev.getX();
                lastY = (int) ev.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                if (Math.abs(lastY-y) > Math.abs(lastX-x)){
                    // 禁用掉也不行啊
                    //return false;
                }
                // 如果上下滑动取消事件
                break;
        }
        return super.dispatchTouchEvent(ev);
    }
}
